﻿<?php ?>
<?php
	include("lib_db.php");

?>
<html>
	<header>
	<script src="js/jquery-2.1.1.js"></script>
	<script src="js/jquery.validate.js"></script>
	</header>
	<body>
	
	<script language="javascript">
		$(document).ready(function(){
    var validator = $("#contact").validate({ 
        rules: { 
            username: "required", 
			txtFullName: "required",
            password: { 
                required: true, 
                minlength: 6, 
            }, 
            cpassword: { 
                equalTo: "#password" 
            }, 
            email: { 
                required: true, 
                email: true
            },
			txtPhone: {
			
			}
        }, 
        messages: { 
            username: "Hãy điền tên đăng nhập.", 
			txtFullName: "Hãy điều đầy đủ họ tên",
            password: { 
                required: "Hãy điền mật khẩu", 
                minlength: "Mật khẩu ít nhất 6 ký tự"
            }, 
            cpassword: { 
                equalTo: "Mật khẩu xác nhận không chính xác" 
            }, 
            email: { 
                required: "Hãy nhập 1 địa chỉ email hợp lệ", 
                email:"Địa chỉ email không hợp lệ"
            },
			txtPhone:{
				minlength: "Sô điện thoại ít nhất 11 số"
			}
        }
    }); 
})
</script> 
		<div id ="wrapper">
			<div id ="header"><?php include("header.php");?></div><!--end header-->		
			<div id ="content">
				<div class="content-header"><?php include ("header-content.php");?></div> <!--end content-header-->
				
						<div class="clear-both"></div>			
				<div class="content-menu">
					<div class ="content-menu-left "><?php include ("content-menu-left.php")?></div>	<!--end content-menu-left -->					
					<div class="content-menu-center">
						<div class="dang-nhap">
							<div class="title-login">
								Đăng nhập
							</div>
							<p style="margin-left:25px;">Quý khách đã có tài khoản xin vui lòng đăng nhập để tiếp tục mua hàng:</p>
							<div class="formcontent">
					
								<form action="" method="post">
								
											<label>Tên Đăng Nhập:</label>
											<input type="text" id="username" value="" name="username" style="height:24px; width:180px;" /><br/>
										
										
											<label>Mật Khẩu:</label>
											<input type="password" id="password" name="password" style="height:24px; width:180px;" /><br/>
										
											
											<input type="checkbox" name="remember" value="" id ="chk"/>
											Nhớ Mật Khẩu<br/>
										
										<div class ="enter">
											<input  id="btn-login" name="login" type="submit" value="Đăng Nhập"/>
											<a href="#"><font color="blue" size="2"> Quên mật khẩu?</font></a>
								
										
										</div>		
										
								</form>				
								
							</div>
						</div>
						
						<div class="from-dang-ky">
							<div class="dinh-dang">
								<div class="title-login">
								Đăng ký tài khoản
								</div>
							
							<form style='width:550px' id='contact' method='post'>
								
										<label>Tên tài khoản:<span class="required">*</span> </label>
										<input type = "text" name ="username" class="required" minlength="6" style="height:24px; width:180px; margin-left: -20px;"> 
										<br/><br/><label>Họ đệm:<span class="required">*</span></label>
										<input  type = "text" name ="txtFullName" class="required" minlength="6" style="height:24px; width:180px; margin-left: -20px;"> <br/><br/>
										<label>Tên:<span class="required">*</span></label>
										<input  type = "text" name ="txtFullName" class="required" minlength="6" style="height:24px; width:180px; margin-left: -20px;"> <br/><br/>
										<label>Email:<span class="required">*</span> </label>
										<input type = "text" name ="email" id="email" class="required email " style="height:24px; width:180px; margin-left: -20px;"> <br/><br/>
										<label>Mật khẩu:<span class="required">*</span></label>
										<input  type = "password" name ="password" class="required" minlength="6" id="password" style="height:24px; width:180px; margin-left: -20px;"> <br/><br/>
										<label>Nhập lại mật khẩu:<span class="required">*</span></label>
										<input  type = "password" name="cpassword" value="" id="cpassword"  equalTo="#password" style="height:24px; width:180px; margin-left: -20px;"> <br/><br/>
										<label>Điện thoại: </label>
										<input  type = "text" name ="txtPhone" value="" class="digits" minlength="10" maxlength="11" style="height:24px; width:180px; margin-left: -20px;"> <br/><br/>
										<label>Tuổi: </label>
										<select name ="cbCountry"style="width:100px; height:25px; margin-left: -20px;">
											<option value ="18">18 </option>
											<option value ="23">23</option>
										</select ><br/>
										<label>Tỉnh/Thành phố </label>
										<select name ="cbCountry" style="width:184px; height:25px; margin	:15px 0px ; margin-left: -20px;">
											<option value ="VietNam">Việt Nam </option>
											<option value ="english">English</option>
										</select><br/>
										
											
										<label>Địa Chỉ: </label>
											<textarea name = "txtAddress" cols ="30" rows ="3" style=" margin-left: -20px;margin-bottom:10px;"></textarea><br/>

										
										<label></label>
										<button id="btn-login" type="submit" name="submit">Đăng ký</button>
										
										<button id="btn-login" type="reset">Nhập lại</button>

								
										
							
							</form>  
						<?php
						
						connect();//Mở function connect CSDL
						
						if(isset($_POST['submit']))
						{
								$user = $_POST["txtuser"];
								$FullName = $_POST["txtFullName"];
								$Email = $_POST["txtEmail"];
							
								
								$pass = $_POST["txtpass"];
								$Age = $_POST["txtAge"];
								if(isset($_POST["txtGender"])){$Gender = $_POST["txtGender"];}
								$Address = $_POST["txtAddress"];
								$Phone = $_POST["txtPhone"];

							
							$sql = "INSERT INTO user (user, FullName, Email, Pass, Age, Gender, Address, Phone) VALUES ('" 
											.$user . "', '" 
											.$FullName . "', '" 
											.$Email . "', '" 
											.md5($pass ). "', '" 
											.$Age . "', '" 
											.$Gender . "', '" 
											.$Address . "', " 
											.$Phone . ")";
											
							
							if (mysql_query(($sql))) {
									 header('location:login.php');
								} 
							
						}
							close();// đóng function connect CSDL
							
						
					
				//	 mysqli_close($con);
					?>
						</div><!--end dinh dang-->
					</div><!--end dang_ky-->
						
					

					</div> <!--end content-menu-center-->
					<div class ="content-menu-right"><?php include ("content-menu-right.php")?></div> <!--end content-menu-right-->
								
				</div> <!--end content-menu-->
			
			</div> <!--end content-->
			<div id ="footer"><?php include("footer.php");?></div><!--end footer-->
			
		
		</div><!--end wapper-->
	</body>
</html>
